﻿using System;
using System.Collections.Generic;
using System.Linq;
using Luna.Data.Budget;

namespace Luna.Model.Budget
{
    internal class Budget : LunaEntity<IBudgetData>, IBudget, IEquatable<IBudget>
    {
        public Budget()
            : base()
        {
        }

        public Budget(Budget P_Base)
            : base(P_Base)
        {
        }

        public Budget(IBudgetData P_Data)
            : base(P_Data)
        {
        }

        public string Comment
        {
            get { return Data.Comment; }
        }

        public IEditableBudget EditableCopy
        {
            get { return new EditableBudget(this); }
        }

        public DateTime? End
        {
            get { return Data.End; }
        }

        public bool LastVersion
        {
            get { return Data.LastVersion; }
        }

        public IEnumerable<ILine> Lines
        {
            get { return DataResolver.Get<IBudgetProvider>().LineGetAllByBudget(this.ID).Select(x => new Line(x)); }
        }

        public Guid MainBudgetID
        {
            get { return Data.MainBudgetID; }
        }

        public string Name
        {
            get { return Data.Name; }
        }

        public DateTime Start
        {
            get { return Data.Start; }
        }

        public bool Validated
        {
            get { return Data.Validated; }
        }

        public bool Equals(IBudget P_Other)
        {
            return P_Other != null && base.Equals(P_Other);
        }
    }
}